package edu.pmfbl.mnr.sem.mcmatm.gui;

import java.awt.*;
import javax.swing.*;

import com.borland.dbswing.*;
import com.borland.dx.dataset.*;

import edu.pmfbl.mnr.sem.mcmatm.app.*;

/**
 * <p>Title: MCMA Test Maker</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2009</p>
 *
 * <p>Company: KrndijaSoft</p>
 *
 * @author Ninoslav Krndija
 * @version 1.0
 */
public class PitanjeInfoPanel extends JPanel
{
  private static PitanjeInfoPanel pitanjeInfoPanel = null;  // PROBA
  AppDataModule appDataModule = AppDataModule.getDataModule();

  JLabel nazivLabel = new JLabel();
  JLabel tekstLabel = new JLabel();
  JLabel bodoviLabel = new JLabel();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JLabel jLabel4 = new JLabel();
  JdbTextField nazivField = new JdbTextField();
  JdbTextField bodoviField = new JdbTextField();
  JdbCheckBox mijesanjeCheckBox = new JdbCheckBox();

  JScrollPane jScrollPane1 = new JScrollPane();
  JdbTextArea tekstText = new JdbTextArea();
  JScrollPane jScrollPane2 = new JScrollPane();
  JdbTextArea infoText = new JdbTextArea();
  JScrollPane jScrollPane3 = new JScrollPane();
  JdbTextArea tacanText = new JdbTextArea();
  JScrollPane jScrollPane4 = new JScrollPane();
  JdbTextArea djelimicanText = new JdbTextArea();
  JScrollPane jScrollPane5 = new JScrollPane();
  JdbTextArea netacanText = new JdbTextArea();

  public PitanjeInfoPanel()
  {
    try
    {
      jbInit();
      setDataSet(appDataModule.getPitanjaDataSet()/*, appDataModule.getViseizboraDataSet()*/);
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }

  public void jbInit() throws Exception
  {
    this.setLayout(null);

    nazivLabel.setText("Naziv pitanja:");
    nazivLabel.setBounds(new Rectangle(8, 8, 67, 15));
    tekstLabel.setText("Tekst pitanja:");
    tekstLabel.setBounds(new Rectangle(8, 54, 66, 15));
    bodoviLabel.setText("Bodovi:");
    bodoviLabel.setBounds(new Rectangle(8, 124, 38, 15));
    jLabel4.setText("Povratna informacija:");
    jLabel4.setBounds(new Rectangle(8, 148, 103, 15));
    jLabel1.setText("Povratna informacija za tačan odgovor:");
    jLabel1.setBounds(new Rectangle(258, 8, 191, 15));
    jLabel2.setText("Povratna informacija za djelimično tačan odgovor:");
    jLabel2.setBounds(new Rectangle(258, 78, 240, 15));
    jLabel3.setText("Povratna informacija za netačan odgovor:");
    jLabel3.setBounds(new Rectangle(258, 148, 204, 15));

    nazivField.setNextFocusableComponent(tekstText);
    nazivField.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
    nazivField.setMargin(new Insets(1, 2, 2, 2));
    nazivField.setText("");
    nazivField.setBounds(new Rectangle(8, 23, 237, 19));
    bodoviField.setNextFocusableComponent(mijesanjeCheckBox);
    bodoviField.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
    bodoviField.setMargin(new Insets(1, 2, 2, 2));
    bodoviField.setHorizontalAlignment(SwingConstants.RIGHT);
    bodoviField.setBounds(new Rectangle(44, 122, 37, 19));
    mijesanjeCheckBox.setNextFocusableComponent(infoText);
    mijesanjeCheckBox.setText("Slučajan redoslijed odgovora");
    mijesanjeCheckBox.setBounds(new Rectangle(83, 121, 164, 23));

    jScrollPane1.setBounds(new Rectangle(8, 69, 237, 46));
    jScrollPane2.setBounds(new Rectangle(8, 163, 237, 46));
    jScrollPane3.setBounds(new Rectangle(258, 23, 237, 46));
    jScrollPane4.setBounds(new Rectangle(258, 93, 237, 46));
    jScrollPane5.setBounds(new Rectangle(258, 163, 237, 46));

    tekstText.setNextFocusableComponent(bodoviField);
    tekstText.setText("");
    infoText.setNextFocusableComponent(tacanText);
    infoText.setText("");
    tacanText.setNextFocusableComponent(djelimicanText);
    tacanText.setText("");
    djelimicanText.setNextFocusableComponent(netacanText);
    djelimicanText.setText("");
    netacanText.setNextFocusableComponent(nazivField);

    this.setPreferredSize(new Dimension(502, 220));

    this.add(nazivLabel);
    this.add(tekstLabel);
    this.add(bodoviLabel);
    this.add(jLabel1);
    this.add(jLabel2);
    this.add(jLabel3);
    this.add(jLabel4);
    this.add(nazivField);
    this.add(jScrollPane1);
    this.add(bodoviField);
    this.add(mijesanjeCheckBox);
    this.add(jScrollPane2);
    this.add(jScrollPane3);
    this.add(jScrollPane4);
    this.add(jScrollPane5);

    jScrollPane5.getViewport().add(netacanText);
    jScrollPane4.getViewport().add(djelimicanText);
    jScrollPane3.getViewport().add(tacanText);
    jScrollPane2.getViewport().add(infoText);
    jScrollPane1.getViewport().add(tekstText);
  }

  public static PitanjeInfoPanel getPitanjeInfoPanel()
  {
    if(pitanjeInfoPanel == null)
      pitanjeInfoPanel = new PitanjeInfoPanel();

    return pitanjeInfoPanel;
  }

  public void setDataSet(DataSet p/*, DataSet v*/)
  {
    nazivField.setDataSet(p);
    bodoviField.setDataSet(p);
    mijesanjeCheckBox.setDataSet(p);
    tekstText.setDataSet(p);
    infoText.setDataSet(p);
    tacanText.setDataSet(p);
    djelimicanText.setDataSet(p);
    netacanText.setDataSet(p);

    nazivField.setColumnName("naziv");
    bodoviField.setColumnName("bodovi");
    mijesanjeCheckBox.setColumnName("mijesanjeodgovora");
    tekstText.setColumnName("tekstpitanja");
    infoText.setColumnName("info");
    tacanText.setColumnName("tacanodgovorinfo");
    djelimicanText.setColumnName("djelimicanodgovorinfo");
    netacanText.setColumnName("netacanodgovorinfo");
  }

}
